package br.com.uniban.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "tb_prova_quest_resp")
public class ProvaQuestoesRespondidas implements Serializable,Comparable<ProvaQuestoesRespondidas> {
	@Transient
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id_prova_quest_resp")
	private Long id;

	@Column(name="is_correta")
	private Boolean isCorreta;

	private Character resposta;
	
	@OneToOne
	@JoinColumn(name = "id_questao", referencedColumnName = "id_questao")
	QuestoesAvulsas questoesAvulsas;

	public ProvaQuestoesRespondidas() {
		super();
	}



	public ProvaQuestoesRespondidas(Boolean isCorreta, Character resposta,
			QuestoesAvulsas questoesAvulsas) {
		super();
		this.isCorreta = isCorreta;
		this.resposta = resposta;
		this.questoesAvulsas = questoesAvulsas;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Boolean getIsCorreta() {
		return isCorreta;
	}

	public void setIsCorreta(Boolean isCorreta) {
		this.isCorreta = isCorreta;
	}

	public Character getResposta() {
		return resposta;
	}

	public void setResposta(Character resposta) {
		this.resposta = resposta;
	}

	public QuestoesAvulsas getQuestoesAvulsas() {
		return questoesAvulsas;
	}

	public void setQuestoesAvulsas(QuestoesAvulsas questoesAvulsas) {
		this.questoesAvulsas = questoesAvulsas;
	}



	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((isCorreta == null) ? 0 : isCorreta.hashCode());
		result = prime * result
				+ ((questoesAvulsas == null) ? 0 : questoesAvulsas.hashCode());
		result = prime * result
				+ ((resposta == null) ? 0 : resposta.hashCode());
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProvaQuestoesRespondidas other = (ProvaQuestoesRespondidas) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (isCorreta == null) {
			if (other.isCorreta != null)
				return false;
		} else if (!isCorreta.equals(other.isCorreta))
			return false;
		if (questoesAvulsas == null) {
			if (other.questoesAvulsas != null)
				return false;
		} else if (!questoesAvulsas.equals(other.questoesAvulsas))
			return false;
		if (resposta == null) {
			if (other.resposta != null)
				return false;
		} else if (!resposta.equals(other.resposta))
			return false;
		return true;
	}


	@Override
	public String toString() {
		return "ProvaQuestoesRespondidas [id=" + id + ", isCorreta="
				+ isCorreta + ", resposta=" + resposta + ", questoesAvulsas="
				+ questoesAvulsas + "]";
	}



	@Override
	public int compareTo(ProvaQuestoesRespondidas o) {
		
		return this.id.compareTo(o.getId());
	}
	

}
